package com.test13;

public class MyTest_02 {

    public static void main(String[] args) throws Exception {
        Book book1 = new Book("Java进阶开发实战", 52.6);
        Book book2 = (Book) book1.clone();
        System.out.println(book1);
        System.out.println(book2);
    }
}

class Book implements Cloneable {

    private String title;

    private double price;

    public Book(String title, double price) {
        this.title = title;
        this.price = price;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Book{" +
                "title='" + title + '\'' +
                ", price=" + price +
                '}';
    }
}
